package com.java110.mall.shop.smo.impl;


import com.java110.mall.shop.dao.IShopSettingServiceDao;
import com.java110.intf.shop.IShopSettingInnerServiceSMO;
import com.java110.dto.shop.ShopSettingDto;
import com.java110.po.shop.ShopSettingPo;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.core.base.smo.BaseServiceSMO;
import com.java110.dto.PageDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName FloorInnerServiceSMOImpl
 * @Description 店铺配置信息内部服务实现类
 * @Author wuxw
 * @Date 2019/4/24 9:20
 * @Version 1.0
 * add by wuxw 2019/4/24
 **/
@RestController
public class ShopSettingInnerServiceSMOImpl extends BaseServiceSMO implements IShopSettingInnerServiceSMO {

    @Autowired
    private IShopSettingServiceDao shopSettingServiceDaoImpl;


    @Override
    public int saveShopSetting(@RequestBody  ShopSettingPo shopSettingPo) {
        int saveFlag = 1;
        shopSettingServiceDaoImpl.saveShopSettingInfo(BeanConvertUtil.beanCovertMap(shopSettingPo));
        return saveFlag;
    }

     @Override
    public int updateShopSetting(@RequestBody  ShopSettingPo shopSettingPo) {
        int saveFlag = 1;
         shopSettingServiceDaoImpl.updateShopSettingInfo(BeanConvertUtil.beanCovertMap(shopSettingPo));
        return saveFlag;
    }

     @Override
    public int deleteShopSetting(@RequestBody  ShopSettingPo shopSettingPo) {
        int saveFlag = 1;
        shopSettingPo.setStatusCd("1");
        shopSettingServiceDaoImpl.updateShopSettingInfo(BeanConvertUtil.beanCovertMap(shopSettingPo));
        return saveFlag;
    }

    @Override
    public List<ShopSettingDto> queryShopSettings(@RequestBody  ShopSettingDto shopSettingDto) {

        //校验是否传了 分页信息

        int page = shopSettingDto.getPage();

        if (page != PageDto.DEFAULT_PAGE) {
            shopSettingDto.setPage((page - 1) * shopSettingDto.getRow());
        }

        List<ShopSettingDto> shopSettings = BeanConvertUtil.covertBeanList(shopSettingServiceDaoImpl.getShopSettingInfo(BeanConvertUtil.beanCovertMap(shopSettingDto)), ShopSettingDto.class);

        return shopSettings;
    }


    @Override
    public int queryShopSettingsCount(@RequestBody ShopSettingDto shopSettingDto) {
        return shopSettingServiceDaoImpl.queryShopSettingsCount(BeanConvertUtil.beanCovertMap(shopSettingDto));    }

    public IShopSettingServiceDao getShopSettingServiceDaoImpl() {
        return shopSettingServiceDaoImpl;
    }

    public void setShopSettingServiceDaoImpl(IShopSettingServiceDao shopSettingServiceDaoImpl) {
        this.shopSettingServiceDaoImpl = shopSettingServiceDaoImpl;
    }
}
